﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess.IService;
using System.Data;
using Utility;
using System.Collections;
using System.Data.SqlClient;
namespace DataAccess.Service
{
    public class ApartmentService : IApartmentService
    {
        public DataTable getAllApartmentTable()
        {
            string CommandText = "select * from Apartment";
            string[] colNames = new string[]
            {
                "apaId",
                "apaName"
            };
            return SQLHelper.generateDataTable(CommandText, colNames);
        }

        public List<String> getPortIdByDorId(int dorId)
        {
            List<String> list = new List<String>();


            string commandText = "select * from StudentAccommodation where dorId=@dorId";
            SqlParameter[] paras = new SqlParameter[]
            {
               new SqlParameter("dorId",dorId)
            };
            SqlDataReader sdReader = SQLHelper.ExecuteReader(commandText, paras);
            while (sdReader.Read())
            {
                list.Add(sdReader["portId"].ToString());
            }
            return list;
        }
    }
}
